<!--
 * @Author: tansq
 * @Date: 2021-09-24 16:25:08
 * @LastEditTime: 2021-11-30 10:22:38
 * @LastEditors: tansq
 * @Description: 项目变更信息
 * @FilePath: \hte-vue-dev\src\views\library\company\components\ProjectInfoChange.vue
 * 可以输入预定的版权声明、个性签名、空行等
-->

<template>
  <div>
    <section>
      <div class="section-header">{{projectNo}}变更信息</div>
      <div class="section-table">
        <div>
          <a-table
            class="hte-table-content"
            :columns="reservationColumns"
            :data-source="sourceData"
            :pagination="false"            
            :loading="tabLoading"
            bordered
            size="middle"
            @change="pageChange"
          >
            <template slot="num" slot-scope="text, record, index">
              {{ (currPageIndex - 1) * currPageSize + parseInt(index) + 1 }}
            </template>
            <template slot="projectNo" slot-scope="text, record, index">
              <a :title="text" @click="handleClick(record)">{{text}}</a> 
            </template>
          </a-table>
        </div>
      </div>
    </section>
  </div>
</template>
<script>
import { getAction } from '@/api/manage'

export default {
  name: 'ProjectInfoChange',
  props: {
    projectBuildId: {
      type: String,
      default: '',
      required:true,
    },
     projectNo: {
     
      default: null,
      required:true,
    },
     companyId: {
      default: null,
      required:true,
    },
     
  },
  components: {
  },
  data() {
    return {
       reservationColumns: [
        {
          title: '序号',
          dataIndex: 'num',
          width: '10%',
          align: 'center',
          scopedSlots: { customRender: 'num' },
        },
        {
          title: '项目编号',
          dataIndex: 'projectNo',
          width: '10%',
          align: 'center',
          scopedSlots: { customRender: 'projectNo' },
        },
        {
          title: '变更事项',
          dataIndex: 'changeOptionName',
          width: '15%',
          align: 'center',
        },
        
        {
          title: '变更前内容',
          dataIndex: 'oldContent',
          width: '25%',
          align: 'center',
        },
        {
          title: '变更后内容',
          dataIndex: 'newContent',
          width: '25%',
          align: 'center',
        },
        {
          title: '核准日期',
          dataIndex: 'changTime',
          width: '15%',
          align: 'center',
        },
      ],
      sourceData: [],
      pagination: {
        total: 0,
        current: 1,
      },
      tabLoading: false,
      currPageIndex: 1,
      currPageSize: 10,
    }
  },
  mounted() {
    // this.queryByChangeProjectBuildId();
  },
  methods: {
    pageChange() {
      this.currPageIndex = page.current
      this.currPageSize = page.pageSize
      this.pagination.current = page.current
      // this.queryByChangeProjectBuildId()
    },
    setSourceData(sourceData = []){
      this.sourceData = [...sourceData]
    },
    getSourceData(approvalTime){
      this.sourceData.forEach(element => {
        element.changTime = approvalTime
      });
      this.sourceData = [...this.sourceData]
      return this.sourceData
    },
    handleClick(record){
      let urlJump = this.$router.resolve({ path: `/approval?projectBuildId=${record.projectBuildId}` })
      window.open(urlJump.href, '_blank');
    },
    /**
     * 
     */
    queryByChangeProjectBuildId() {
      let that = this
      this.tabLoading = true
      var param = {projectBuildId:this.projectBuildId,projectNo:this.projectNo,companyId:this.companyId}
      getAction('/libraryCompany/hteLibCompany/queryByChangeProjectBuildId',param).then((res) => {
        if (res.code == 200 && res.result) {
         
          res.result.forEach((item, index) => {
            item.key = index
          })
          this.sourceData = res.result
          this.tabLoading = false
        } else {
          this.$message.warning('数据加载失败:' + res.message)
          
        }
      }).finally(item=>{
          this.tabLoading = false
      })
    },
  },
}
</script>
<style lang="less" scoped>
@import '~@assets/less/hte-main.less';
</style>